/*
    Borealis Library
    A library of commonly used hydrological modeling building blocks

    Copyright (C) 2008  Chris Marsh

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/


#include <cppunit\CompilerOutputter.h>
#include <cppunit\extensions/TestFactoryRegistry.h>
#include <cppunit\ui\text\TestRunner.h>
//core tbb
#include <tbb\task_scheduler_init.h>
#include <borealis\Borealis.hpp>


#ifdef _DEBUG
	#pragma comment(lib,"cppunitd.lib")
	#pragma comment(lib,"borealis_debug.lib")
#else
	#pragma comment(lib,"cppunit.lib")
	#pragma comment(lib,"borealis.lib")
	#pragma comment(lib,"tbb.lib")
#endif



int main(int argc, char* argv[])
{
	tbb::task_scheduler_init init;//single thread for debugging

	//Open a log file
	try
	{
		Borealis::Logger::GetInstance().InitLog("Borealis_Debug_log.log");
	}
	catch (std::runtime_error e)
	{
		std::cout << "Failed to open logging file...Aborting Tests" << std::endl;
		return -1;
	}



	// Get the top level suite from the registry
	CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();

	// Adds the test to the list of test to run
	CppUnit::TextUi::TestRunner runner;
	runner.addTest( suite );

	// Change the default outputter to a compiler error format outputter
	runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),
		std::cerr ) );
	// Run the tests.

		bool wasSucessful = runner.run();



	// Return error code 1 if the one of test failed.
	return wasSucessful ? 0 : 1;
}
